//
//  PTContactDetail.swift
//  PointTest28
//
//  Created by sc-chen on 2023/6/26.
//

import SwiftUI

struct PTContactDetail: View {
    var contact: PTContact
    
    var body: some View {
        VStack {
            HStack {
                if let data = contact.icon {
                    if let image = UIImage(data: data) {
                        Image(uiImage: image)
                            .aspectRatio(contentMode: .fit)
                            .frame(width: 60,height: 60)
                            .clipShape(Circle())
                            .padding(.top,10)
                            .padding(.leading,10)
                    }
                }else{
                    Image("defaultIcon")
                        .aspectRatio(contentMode: .fit)
                        .frame(width: 60,height: 60)
                        .clipShape(Circle())
                        .padding(.top,10)
                        .padding(.leading,10)
                }
                Spacer()
            }
            HStack {
                Text("姓名: \(contact.name)")
                    .font(.system(size: 13))
                    .padding()
                    .padding(.leading,10)
                    .padding(.top,20)
                Spacer()
            }
            HStack {
                Text("手机号: \(contact.number)")
                    .font(.system(size: 13))
                    .padding()
                    .padding(.leading,10)
                Spacer()
            }
            
            Spacer()
        }
    }
}

struct PTContactDetail_Previews: PreviewProvider {
    static var cn = PTContact(icon: nil, name: "", number: "")
    static var previews: some View {
        PTContactDetail(contact: cn)
    }
}
